package com.guoyh.procommon.activity

import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.databinding.DataBindingUtil
import com.blankj.utilcode.util.ViewUtils
import com.guoyh.bilbase.ext.getIntentStr
import com.guoyh.baseutils.utils.ActStartUtils
import com.guoyh.bilui.ext.init
import com.guoyh.mcommon.R
import com.guoyh.procommon.base.BaseWebViewActivity
import com.guoyh.mcommon.databinding.MWebActivityBinding


/**
 * 通用的 Web 加载格式
 */
class CommonWebActivity : BaseWebViewActivity() {

    lateinit var mDataBinding: MWebActivityBinding

    companion object {
        const val Web_Url = "Web_Url"

        fun start(cont: Context,linkS:String) {
            val bundle = Bundle()
            bundle.putString(Web_Url,linkS)
            ActStartUtils.startActivity(cont, CommonWebActivity::class.java,bundle)
        }
    }


    private val link by lazy {
        getIntentStr(Web_Url)
    }

    var movieUrl =
        "https://sv.baidu.com/videoui/page/videoland?context=%7B%22nid%22%3A%22sv_5861863042579737844%22%7D&pd=feedtab_h5"


    override fun onCreate(savedInstanceState: Bundle?) {
        mDataBinding = DataBindingUtil.bind(ViewUtils.layoutId2View(R.layout.m_web_activity))!!

        super.onCreate(savedInstanceState)
    }


    override fun getUrl() = link

    override fun getWebViewId(): Int = R.id.webActX5View

    override fun getLayout(): View {
        return mDataBinding.root
    }

    override fun toSetTitle(title: String?) {
        mDataBinding.webActStb.setTitle(title)
        mDataBinding.webActStb.init({
            back()
        })
    }

    override fun getLoadingView() = mDataBinding.webActX5View
}